import { CrudService, CrudRequest, GetManyDefaultResponse, CreateManyDto } from '@nest-crud/crud';
import { getController } from '../factory/controller/type-utils';

export interface CrudControllerProp<T> {
  service: CrudService<T>;
}
export type ControllerMethodType<T> = {
  getManyBase: {
    getManyBase(req: CrudRequest): Promise<GetManyDefaultResponse<T> | T[]>;
  };
  getOneBase: {
    getOneBase(req: CrudRequest): Promise<T>;
  };
  createOneBase: {
    createOneBase(req: CrudRequest, dto: T): Promise<T>;
  };
  createManyBase: {
    createManyBase(req: CrudRequest, dto: CreateManyDto<T>): Promise<T[]>;
  };
  updateOneBase: {
    updateOneBase(req: CrudRequest, dto: Partial<T>): Promise<T>;
  };
  replaceOneBase: {
    replaceOneBase(req: CrudRequest, dto: T): Promise<T>;
  };
  deleteOneBase: {
    deleteOneBase(req: CrudRequest): Promise<void | T>;
  };
  recoverOneBase: {
    recoverOneBase(req: CrudRequest): Promise<void | T>;
  };
};
export type ControllerMethods = keyof ControllerMethodType<unknown>;
export type CurdController<T> = getController<T, never>;
